<script>

function openAdd(id){
	location.href='../posts/addf/'+id;
}
</script>

<?php



$cookie = $this->Facebook->get_cookie();

?>


	<script src="http://connect.facebook.net/en_US/all.js"></script>
    <script>	var next = ""
				var prev = ""
		function convertToUntil(untilString){
			
			nextElements = untilString.split('&');
			until = nextElements[(nextElements.length-1)];
			date = until.split('=')[1].replace('%3A',':').replace('%3A',':');
			date = date.replace('%2B','+');
			
			return date;
		}
		
		function convertToSince(sinceString){
			
			nextElements = sinceString.split('&');
			since = nextElements[(nextElements.length-1)];
			date = since.split('=')[1].replace('%3A',':').replace('%3A',':');
			date = date.replace('%2B','+');	
			
			return date;
		}
		
		function nextFunc() { date=convertToUntil(next); FB.api('/me/photos', {until:date, limit:24 }, function(response) {
			
				var allphotos = response['data'];
				var photo24 = response.data;
				for(var i=0;i<photo24.length;i++){
					var pos = i+1;
					var posID = "picpos"+pos.toString();
					var picpos = document.getElementById(posID);
					picpos.innerHTML = "<center><img src=" + photo24[i]['picture'] + "></center>";
				}
			prev = response.paging.previous;
			next = response.paging.next;

			});
		}
		
			function previousFunc() { 	date=convertToSince(prev); FB.api('/me/photos', {since:date, limit:24 }, function(response) {

				  	var allphotos = response['data'];
					var photo24 = response.data;
					
					for(var i=0;i<photo24.length;i++){
						var pos = i+1;
						var posID = "picpos"+pos.toString();
						var picpos = document.getElementById(posID);
						picpos.innerHTML = "<center><img src=" + photo24[i]['picture'] + "></center>";
					}
					prev = response.paging.previous;
					next = response.paging.next;

				});
			}
		</script></head>
  <body>

	Your Facebook Photos:
	<center><table width="735" height="477" border="0">
	  <tr>
	    <td id="picpos1"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos2"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos3"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos4"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos5"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos6"><?php echo $html->image("loading.gif"); ?></td>
	  </tr>
	  <tr>
	    <td id="picpos7"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos8"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos9"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos10"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos11"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos12"><?php echo $html->image("loading.gif"); ?></td>
	  </tr>
	  <tr>
	    <td id="picpos13"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos14"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos15"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos16"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos17"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos18"><?php echo $html->image("loading.gif"); ?></td>
	  </tr>
	  <tr>
	    <td id="picpos19"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos20"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos21"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos22"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos23"><?php echo $html->image("loading.gif"); ?></td>
	    <td id="picpos24"><?php echo $html->image("loading.gif"); ?></td>
	  </tr>
	</table></center>
	<center><form>

	<input type="button" id="buttonPrev" value="previous" onclick="previousFunc()" size=50 />
	<input type="button" id="buttonNext" value="next" onclick="nextFunc()" size=50 />
	</form></center>
    <?php  $this->Facebook->start_facebook(); ?>

 
	<script>

		FB.api('/me/photos',{ limit:24}, function(response) {

			var photo24 = response.data;
			for(var i=0;i<photo24.length;i++){
				var pos = i+1;
				var posID = "picpos"+pos.toString();
				var picpos = document.getElementById(posID);
				picpos.innerHTML = "<center><img src=" + photo24[i]['picture'] + " onclick='openAdd(\""+photo24[i]['id']+"\");'></center>";
			}
			prev = response.paging.previous;
			next = response.paging.next;
		
		});
		

		
		
    </script>
  </body>
</html>